import role from '@/models/role';
import { ObjectId } from 'mongodb';

export const getList = async () => {
  const res = await role.getList();
  return res;
};

export const deleteRole = async (params) => {
  const { _id } = params;
  const res = await role.deleteOne({ _id: new ObjectId(_id) });
  return res;
};

export const addRole = async (params) => {
  const res = await role.insert(params);
  return res;
};

export const editRole = async (params) => {
  const { _id, ...otherParams } = params;
  const res = await role.update(otherParams, { _id: new ObjectId(_id) });
  return res;
};
